package com.ln.lnzw.activity;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.widget.ImageView;

import com.flyco.tablayout.SlidingTabLayout;
import com.ln.lnzw.R;
import com.ln.lnzw.adapter.NewsFragmentPagerAdapter;
import com.ln.lnzw.app.AppConstant;
import com.ln.lnzw.base.BaseActivity;
import com.ln.lnzw.fragment.AnnouncementFragment;
import com.ln.lnzw.fragment.ImplementationSubjectFragment;
import com.ln.lnzw.fragment.ServiceObjectFragment;
import com.ln.lnzw.fragment.TypeOfAuthorityFragment;
import com.ln.lnzw.view.CustomViewPager;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by wuwei on 2018/4/16.
 * 办事服务
 */

public class HandleaffairsServiceActivity extends BaseActivity {

    @BindView(R.id.iv_back)
    ImageView ivBack;
    @BindView(R.id.SlidingTabLayout)
    com.flyco.tablayout.SlidingTabLayout SlidingTabLayout;
    @BindView(R.id.viewpager)
    CustomViewPager viewpager;
    private NewsFragmentPagerAdapter mAdapetr;
    private List<String> nameFragment;
    private List<Fragment> fragmentList;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_handleaffairs_service);
        ButterKnife.bind(this);
        initFragment();

    }
    private void initView() {
        mAdapetr = new NewsFragmentPagerAdapter(activity.getSupportFragmentManager(), fragmentList, nameFragment);
        viewpager.setAdapter(mAdapetr);
        viewpager.setOffscreenPageLimit(2);
        viewpager.setCurrentItem(0, false);
        SlidingTabLayout.setViewPager(viewpager);

    }
    private void initFragment() {
        nameFragment = new ArrayList<>();
        fragmentList = new ArrayList<>();
        nameFragment.add("实施主体");
        nameFragment.add("职权类型");
        nameFragment.add("服务对象");

                ImplementationSubjectFragment implementationSubjectFragment = new ImplementationSubjectFragment();
                Bundle b = new Bundle();
//                b.putString("url", AppConstant.IMPLEMENTATION_SUBJECT_URL);
                b.putString("name",nameFragment.get(0));
                implementationSubjectFragment.setArguments(b);
                fragmentList.add(implementationSubjectFragment);


                TypeOfAuthorityFragment typeOfAuthorityFragment = new TypeOfAuthorityFragment();
                Bundle b1 = new Bundle();
                b1.putString("url", AppConstant.WORKDYNAMICS_URL);
                b1.putString("name",nameFragment.get(1));
                typeOfAuthorityFragment.setArguments(b1);
                fragmentList.add(typeOfAuthorityFragment);


                ServiceObjectFragment serviceObjectFragment = new ServiceObjectFragment();
                Bundle b2 = new Bundle();
                b2.putString("url", AppConstant.POLICIESREGULATIONS_URL);
                b2.putString("moreUrl", AppConstant.POLICIESREGULATIONS_MORE_URL);
                b2.putString("name",nameFragment.get(2));
                serviceObjectFragment.setArguments(b2);
                fragmentList.add(serviceObjectFragment);


        initView();
    }

    @OnClick(R.id.iv_back)
    public void onViewClicked() {
        finish();
    }
}
